const https = require("https");
const fs = require("fs");
const path = require("path");

https.get("https://www.jd.com", (res) => {
  let result = "";
  res.on("data", (chunk) => {
    result += chunk;
  });
  res.on("end", () => {
    fs.writeFile(path.join(__dirname, "./jd.html"), result, (err) => {
      if (err) throw err;
      console.log("京东写完了");
    });
  });
});
